import 'package:flutter/material.dart';
import 'package:flutter_projectname_getx/entity/base_entity.dart';
import 'package:flutter_projectname_getx/service/test_service.dart';
import 'package:flutter_switch/flutter_switch.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:get/get.dart';
import 'package:toggle_switch/toggle_switch.dart';

import 'test_logic.dart';

class TestPage extends StatefulWidget {
  @override
  _TestPageState createState() => _TestPageState();
}

class _TestPageState extends State<TestPage> {
  final TestLogic logic = Get.put(TestLogic());

  bool  toggle = false;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    TestServices.test<BaseEntity>().then((value) => print(value.msg));
  }
  @override
  Widget build(BuildContext context) {
    return GetBuilder<TestLogic>(
      builder: (controller) {
        return Scaffold(
          body: Container(
            child: Column(
              children: [
                FaIcon(FontAwesomeIcons.home),

                FlutterSwitch(
                  width: 125.0,
                  height: 50.0,
                  valueFontSize: 25.0,
                  toggleSize: 45.0,
                  value: toggle,
                  borderRadius: 30.0,
                  padding: 0.0,
                  showOnOff: false,
                  onToggle: (val) {
                    setState(() {
                      toggle = val;
                    });
                  },
                ),

                FlutterSwitch(
                  width: 125.0,
                  height: 50.0,
                  valueFontSize: 25.0,
                  toggleSize: 45.0,
                  value: toggle,
                  borderRadius: 30.0,
                  padding: 10.0,
                  showOnOff: false,
                  onToggle: (val) {
                    setState(() {
                      toggle = val;
                    });
                  },
                ),

                // Here, default theme colors are used for activeBgColor, activeFgColor, inactiveBgColor and inactiveFgColor
                ToggleSwitch(
                  initialLabelIndex: 0,
                  labels: ['America', 'Canada', 'Mexico'],
                  onToggle: (index) {
                    print('switched to: $index');
                  },
                ),

                ToggleSwitch(
                  minWidth: 90.0,
                  minHeight: 50.0,
                  fontSize: 16.0,
                  initialLabelIndex: 1,
                  activeBgColor: Colors.green,
                  activeFgColor: Colors.white,
                  inactiveBgColor: Colors.grey,
                  inactiveFgColor: Colors.grey[900],
                  labels: ['Tall', 'Grande', 'Venti'],
                  onToggle: (index) {
                    print('switched to: $index');
                  },
                ),

                ToggleSwitch(
                  minWidth: 90.0,
                  cornerRadius: 20.0,
                  activeBgColor: Colors.cyan,
                  activeFgColor: Colors.white,
                  inactiveBgColor: Colors.grey,
                  inactiveFgColor: Colors.white,
                  labels: ['YES', 'NO'],
                  icons: [FontAwesomeIcons.stamp, FontAwesomeIcons.times],
                  onToggle: (index) {
                    print('switched to: $index');
                  },
                ),

                ToggleSwitch(
                  minWidth: 90.0,
                  initialLabelIndex: 1,
                  cornerRadius: 20.0,
                  activeFgColor: Colors.white,
                  inactiveBgColor: Colors.grey,
                  inactiveFgColor: Colors.white,
                  labels: ['Male', 'Female'],
                  icons: [FontAwesomeIcons.stamp, FontAwesomeIcons.times],
                  activeBgColors: [Colors.blue, Colors.pink],
                  onToggle: (index) {
                    print('switched to: $index');
                  },
                ),

                ToggleSwitch(
                  minWidth: 90.0,
                  minHeight: 70.0,
                  initialLabelIndex: 2,
                  cornerRadius: 20.0,
                  activeFgColor: Colors.white,
                  inactiveBgColor: Colors.grey,
                  inactiveFgColor: Colors.white,
                  labels: ['', '', ''],
                  icons: [
                    FontAwesomeIcons.mobile,
                    FontAwesomeIcons.print,
                    FontAwesomeIcons.bold
                  ],
                  iconSize: 30.0,
                  activeBgColors: [Colors.blue, Colors.pink, Colors.purple],
                  onToggle: (index) {
                    print('switched to: $index');
                  },
                ),

              ],
            ),
          ),
        );
      },
    );
  }


  @override
  void dispose() {
    Get.delete<TestLogic>();
    super.dispose();
  }
}